
<!DOCTYPE html>
<html lang="en">

<head>

    <include file="Public/header" />

</head>

<body>

    <div class="container">
        <div class="row">
            <div class="col-md-4 col-md-offset-4">
                <div class="login-panel panel panel-default">
                    <div class="panel-heading">
                        <h3 class="panel-title">登录</h3>
                    </div>
                    <div class="panel-body">
                        <form role="form" id="form">
                            <fieldset>
                                <div class="form-group">
                                	<input class="form-control" id="username" name="username" type="text" 
                                	required="" data-parsley-minlength="4" data-parsley-minlength-message="用户名不小于4位" 
                                	data-parsley-maxlength="20" data-parsley-maxlength-message="用户名不大于20位" 
                                	data-parsley-required-message="用户名 必填" placeholder="请输入用户名">
                                </div>
                                <div class="form-group">
									<input class="form-control" id="password" name="password" 
									type="password" required="" data-parsley-minlength="6" 
									data-parsley-minlength-message="登录密码不小于6位" 
									data-parsley-maxlength="20" data-parsley-maxlength-message="登录密码不大于20位"
									 data-parsley-required-message="登录密码 必填" placeholder="请输入登录密码">
                                </div>
                                <!-- <div class="checkbox">
                                    <label>
                                        <input name="remember" type="checkbox" value="Remember Me">Remember Me
                                    </label>
                                </div> -->
                                <!-- Change this to a button or input when using this as a form -->
                                <button  class="btn btn-lg btn-success btn-block">登 录</button>
                            </fieldset>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <include file="Public/footer" />
	
	
	<script type="text/javascript" src="__RAC__/js/parsleyjs/parsley.min.js"></script>
	
	<script type="text/javascript">
	$(function () {
		$('#form').parsley().on('form:submit', function() {
        	var obj = $('#form').serialize();
        	var layer_index = null;
        	
           	$.ajax({
           	    type: "POST",
           	    url: "{:U('Login/login')}",
           	    data: obj,// 要提交的表单
           	    dataType: 'json',
           	    beforeSend: function(){
   					layer_index = layer.load(1, {
   					  	shade: [0.1, '#ccc'] //0.1透明度的白色背景
   					});
   				},
           	    success: function (data, response) {
           	    	layer.close(layer_index);
           	    	if (data.flag > 0) {
           	    		location.href = "{:U('Index/index')}";
           	    		layer.msg(data.msg);
           	    	} else {
           	    		layer.msg(data.msg);
           	    	}
           	    },
           	    error: function (error) {
           	    	layer.close(layer_index);
           	    	layer.msg('error');
           	    }
           	  }); 
        	  
        	 return false;
        });
		
	});
	
	</script>
</body>

</html>
